﻿<Page
    x:Class="XnReader.WinRT.Forms.FrameArticleList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:XnReader.WinRT.Forms"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Helper="using:XnReader.WinRT.Helper"
    xmlns:Controlx="using:XnReader.WinRT.Controlx" mc:Ignorable="d">
    <Page.Resources>
        <Helper:CoverConverter x:Key="ConverterCover"/>
    <CollectionViewSource x:Name="cvsArticleList"/>
        <DataTemplate x:Key="ItemTemplateHistoryOnline">
            <Border VerticalAlignment="Top" HorizontalAlignment="Left" Width="125" Height="155" Padding="0">
                <Border.Background>
                    <ImageBrush ImageSource="/Assets/imgbg.gif"/>
                </Border.Background>
                <Border Width="120" Height="150" Margin="-5,-5,0,0" >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"></RowDefinition>
                            <RowDefinition Height="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Image Grid.RowSpan="2" Source="{Binding articleid, Converter={StaticResource ConverterCover}}"/>
                        <Border Grid.Row="1" Background="#B2000000">
                            <TextBlock Text="{Binding articlename}" TextAlignment="Center" Foreground="White" FontSize="12"></TextBlock>
                        </Border>
                    </Grid>
                </Border>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="ItemTemplateHistoryLocal">
            <Border VerticalAlignment="Top" HorizontalAlignment="Left" Width="125" Height="155" Padding="0">
                <Border.Background>
                    <ImageBrush ImageSource="/Assets/imgbg.gif"/>
                </Border.Background>
                <Border Width="120" Height="150" Margin="-5,-5,0,0" Background="#FF01B2D3">
                    <Grid VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="50"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="50"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel>
                            <Border Height="21" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="21" BorderBrush="White" BorderThickness="0,0,1,0"></Border>
                        </StackPanel>
                        <Border Grid.Column="1" Height="20" Width="20" Margin="0,115,0,0" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock  Text="{Binding intro}" FontSize="14" TextAlignment="Center" Foreground="White" FontFamily="Segoe UI Symbol" Margin="0,4,0,0"></TextBlock>
                        </Border>
                        <Border Grid.Column="3" BorderBrush="White" BorderThickness="2" Height="120" Width="30" VerticalAlignment="Center">
                            <Border VerticalAlignment="Center" Width="20">
                                <TextBlock Text="{Binding articlename}" Foreground="White" FontSize="14" TextAlignment="Center" TextWrapping="Wrap"></TextBlock>
                            </Border>
                        </Border>
                    </Grid>
                </Border>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="ItemTemplateBookcaseOnline">
            <Border VerticalAlignment="Top" HorizontalAlignment="Left" Width="125" Height="155" Padding="0">
                <Border.Background>
                    <ImageBrush ImageSource="/Assets/imgbg.gif"/>
                </Border.Background>
                <Border Width="120" Height="150" Margin="-5,-5,0,0" >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"></RowDefinition>
                            <RowDefinition Height="20"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Image Grid.RowSpan="2" Source="{Binding articleid, Converter={StaticResource ConverterCover}}"/>
                        <Border Grid.Row="1" Background="#B2000000">
                            <TextBlock Text="{Binding articlename}" TextAlignment="Center" Foreground="White" FontSize="12"></TextBlock>
                        </Border>
                    </Grid>
                </Border>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="ItemTemplateBookcaseLocal">
            <Border VerticalAlignment="Top" HorizontalAlignment="Left" Width="125" Height="155" Padding="0">
                <Border.Background>
                    <ImageBrush ImageSource="/Assets/imgbg.gif"/>
                </Border.Background>
                <Border Width="120" Height="150" Margin="-5,-5,0,0" Background="#FF01B2D3">
                    <Grid VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="50"></ColumnDefinition>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="50"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <StackPanel>
                            <Border Height="21" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="36" BorderBrush="White" BorderThickness="0,0,1,1"></Border>
                            <Border Height="21" BorderBrush="White" BorderThickness="0,0,1,0"></Border>
                        </StackPanel>
                        <Border Grid.Column="1" Height="20" Width="20" Margin="0,115,0,0" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <TextBlock  Text="" FontSize="14" TextAlignment="Center" Foreground="White" FontFamily="Segoe UI Symbol" Margin="0,4,0,0"></TextBlock>
                        </Border>
                        <Border Grid.Column="3" BorderBrush="White" BorderThickness="2" Height="120" Width="30" VerticalAlignment="Center">
                            <Border VerticalAlignment="Center" Width="20">
                                <TextBlock Text="{Binding articlename}" Foreground="White" FontSize="14" TextAlignment="Center" TextWrapping="Wrap"></TextBlock>
                            </Border>
                        </Border>
                    </Grid>
                </Border>
            </Border>
        </DataTemplate>
        <Helper:TemplateSelector x:Key="GridViewTemplateSelector"
                                    ItemTemplateHistoryOnline="{StaticResource ItemTemplateHistoryOnline}"
                                    ItemTemplateHistoryLocal="{StaticResource ItemTemplateHistoryLocal}"
                                    ItemTemplateBookcaseOnline="{StaticResource ItemTemplateBookcaseOnline}"
                                    ItemTemplateBookcaseLocal="{StaticResource ItemTemplateBookcaseLocal}">
        </Helper:TemplateSelector>
    </Page.Resources>
    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="../Assets/background_default.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="90"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Border  VerticalAlignment="Center">
            <Controlx:CommandDx x:Name="header"></Controlx:CommandDx>
        </Border>
        <ProgressRing Width="80" Height="80" x:Name="pbLoading" Grid.RowSpan="2" IsActive="True"></ProgressRing>
        <GridView
            x:Name="itemGridView"
            AutomationProperties.AutomationId="ItemsGridView"
            AutomationProperties.Name="Items"
            TabIndex="1"
            Grid.Column="1"
            Grid.Row="1"
            ItemsSource="{Binding Source={StaticResource cvsArticleList}}"
            ItemTemplateSelector="{StaticResource GridViewTemplateSelector}"
            IsItemClickEnabled="True" 
            ItemClick="ItemGridViewItemClick"
            SelectionMode="Multiple"
            IsSwipeEnabled="false" >
        </GridView>
    </Grid>
</Page>